<?php

Route::group(['prefix' => 'api', 'namespace' => 'Customer\Api'], function(){
    Route::post('wechat-pay-notify', 'DeviceController@wechatPayNotify');
});

//微信端
Route::group(['middleware' => ['simulate','oauth'], 'namespace' => 'Customer'], function(){
    //异步接口
    Route::group(['namespace' => 'Api', 'prefix' => 'api'], function(){
        //用户
        Route::group(['prefix' => 'user'], function(){
            //设置用户信息
            Route::post('setInfo', 'UserController@updateUserInfo');
            //售后服务
            Route::post('addAfterService', 'UserController@addAfterService');
        });
        //设备
        Route::group(['prefix' => 'device'], function(){
            // 绑定
            Route::post('bind', 'DeviceController@bind');
            // 控制指令
            Route::post('control', 'DeviceController@control');
            // 解绑
            Route::post('unbind', 'DeviceController@unbind');
            //
            Route::post('pay', 'DeviceController@pay');
        });
    });

    //同步页面
    Route::group(['namespace' => 'Pages'], function(){
        //用户
        Route::group(['prefix' => 'user'], function(){
            //信息管理页面
            Route::get('infoManage', 'UserController@addUserManage');
            //个人信息页面
            Route::get('personal', 'UserController@addUserPersonalInfo');
            //售后服务页面
            Route::get('afterService', 'UserController@addUserAfterServiceInfo');
            //缴费查询
            Route::get('checkPayment', 'UserController@addUserCheckPayment');
            //购买流量
            Route::get('payFlux', 'UserController@addUserPayFlux');
        });

        //微信端首页，水机控制页面
        Route::get('index', 'DeviceController@index');
        //设备
        Route::group(['prefix' => 'device'], function(){
            //绑定页面
            Route::get('bind', 'DeviceController@bind');
            //输入设备码页面
            Route::get('bind/code', 'DeviceController@codeBind');
            //设备信息页面
            Route::get('deviceInfo', 'DeviceController@info');
            //解绑页面
            Route::get('unbind', 'DeviceController@unbind');
        });
    });
});
//后台管理
Route::group(['middleware' => ['simulate', 'redirect', 'admin'], 'prefix' => 'admin', 'namespace' => 'Admin'], function(){
    //异步接口
    Route::group(['namespace' => 'Api', 'prefix' => 'api'], function(){
        //用户
        Route::group(['prefix' => 'user'], function(){
            //登录
            Route::post('login', 'UserController@login');
            //获取角色列表
            Route::get('roles', 'UserController@roles');
            //添加管理员
            Route::post('add', 'UserController@add');
            //更新管理员信息
            Route::post('update', 'UserController@updateAdminInfo');
            //删除管理员
            Route::post('delete', 'UserController@deleteAdmin');
            //修改密码
            Route::post('updatePassword', 'UserController@updatePassword');
            //获取管理员信息
            Route::get('edit', 'UserController@getAdminInfoById');
            //获取用户信息
            Route::get('customer/edit', 'UserController@getUserInfoById');
            //修改用户信息
            Route::post('customer/update', 'UserController@updateUserInfo');
            //设置售后服务记录是否已提醒
            Route::post('afterService/process', 'UserController@process');
            //登出
            Route::post('logout', 'UserController@logout');
        });
        //设备
        Route::group(['prefix' => 'device'], function(){
            //滤芯提醒页面是否已提醒切换状态
            Route::post('filter', 'DeviceController@processFilterReminder');
            //流量提醒页面是否已提醒切换状态
            Route::post('flow', 'DeviceController@processFlowReminder');
            //添加安装信息
            Route::post('addInstallInfo', 'DeviceController@addInstallInfo');
            //获取安装信息
            // Route::get('installInfo', 'DeviceController@getInstallInfoById');
            //修改安装信息
            Route::post('updateInstallInfo', 'DeviceController@updateInstallInfo');
            //删除安装信息
            Route::post('deleteInstallInfo', 'DeviceController@deleteInstallInfo');
            //添加维护信息
            Route::post('addMaintainInfo', 'DeviceController@addMaintainInfo');
            //获取维护信息
            // Route::get('maintainInfo', 'DeviceController@getMaintainInfoById');
            //修改维护信息
            Route::post('updateMaintainInfo', 'DeviceController@updateMaintainInfo');
            //删除维护信息
            Route::post('deleteMaintainInfo', 'DeviceController@deleteMaintainInfo');
            //处理维护信息
            Route::post('processMaintainInfo', 'DeviceController@processMaintainInfo');
            //停机
            Route::post('halt', 'DeviceController@halt');
            //充流量，旧版本单片机程序充值流量入口
            Route::post('recharge', 'DeviceController@recharge');
            //续费，新版本单片机程序充值入口包括 流量和天数
            Route::post('recharge/mode', 'DeviceController@modeRecharge');
            //减少流量
            Route::post('reduce', 'DeviceController@reduce');
            //减少续费的值
            Route::post('reduce/mode', 'DeviceController@modeReduce');
            //异步获取安装地址
            Route::post('install-address', 'DeviceController@getInstallAddressByDeviceCode');
            //获取安装人信息
            Route::get('installers', 'DeviceController@getInstallerByQuery');
            //获取经销商信息
            Route::get('dealers', 'DeviceController@getDealerByQuery');
        });
        Route::group(['prefix' => 'more'], function(){
            Route::post('price', 'ConfigController@storePrice');
            Route::post('message/bind', 'ConfigController@storeBindMessage');
            Route::post('set-discharge-money', 'DeviceController@setDischargeMoney');
        });
    });
    //同步页面
    Route::group(['namespace' => 'Pages'], function(){
        //用户
        Route::group(['prefix' => 'user'], function(){
            //登录页面
            Route::get('login', 'UserController@login');
            //管理员列表
            Route::get('index', 'UserController@index');
            //用户列表
            Route::get('customers', 'UserController@customerList');
            //售后服务列表
            Route::get('afterServices', 'UserController@afterServiceList');
        });
        //设备
        Route::group(['prefix' => 'device'], function(){
            //设备列表
            Route::get('index', 'DeviceController@index');
            //设备历史记录
            Route::get('history', 'DeviceController@history');
            //设备提醒列表
            Route::group(['prefix' => 'reminder'], function(){
                // 剩余流量、天数
                Route::get('flow', 'DeviceController@flowRemindList');
                // 剩余滤芯寿命
                Route::get('filter', 'DeviceController@fliterRemindList');
                // 设备净水 TDS 提醒
                Route::get('tds', 'DeviceController@tdsRemindList');
                // 设备非正常工作状态提醒
                Route::get('status', 'DeviceController@statusRemindList');
            });
            //安装信息列表
            Route::get('installInfos', 'DeviceController@installInfoList');
            //维护信息列表
            Route::get('maintainInfos', 'DeviceController@maintainInfoList');
            //维护信息历史列表
            Route::get('maintainHistory', 'DeviceController@findmaintainInfoByCustomerName');
            //流量充值
            Route::get('chargeRecords', 'DeviceController@chargeList');
            //流量充值历史记录
            Route::get('chargeRecords/history', 'DeviceController@chargeHistory');
            //经销商流量充值历史记录
            Route::get('chargeRecords/dealer', 'DeviceController@chargeListAboutDealer');
            //经销商流量充值历史记录导出
            Route::get('chargeRecords/export', 'DeviceController@chargeListAboutDealerExport');
            //故障信息
            Route::get('faults', 'DeviceController@faults');
        });
        //更多
        Route::group(['prefix' => 'more'], function(){
            Route::get('price', 'ConfigController@price');
            Route::get('message/bind', 'ConfigController@bindMessage');
        });
    });
});

//某网站维护中
Route::get('device/index', '\App\Http\Controllers\Customer\Pages\DeviceController@down');

Route::get('menu', '\App\Http\Controllers\Customer\Api\WeChatController@createMenu');